package observer;

import java.awt.Point;
import java.util.Observable;
import java.util.Random;

public class Creature extends Observable implements Runnable{
	Point position;
	
	public Creature(){
		position = new Point(25, 25);
	}
	
	public Creature(Point p){
		position = new Point(p);
	}
	
	public Creature(int PosX, int PosY){
		position = new Point(PosX, PosY);
	}
	
	public Point getPosition() {
		return position;
	}
		
	// Déplacements aléatoirs
	public void move(){
		if(position.x >= 50)
			position.x--;
		if(position.y >= 50)
			position.y--;
		else{
			Random r = new Random();
			int rdm = r.nextInt(4);
			
			switch(rdm){
				case 1 :
					position.x ++;
					break;
				case 2 :
					position.x--;
					break;
				case 3 :
					position.y++;
					break;
				case 4 :
					position.y--;
					break;
			}
		}
	}

	@Override
	public void run(){}
}
